import { Model } from './data'

export interface UserInfo {
  avatarUrl?: string
  city?: string
  country?: string
  gender?: number
  language?: string
  nickName?: string
  openId?: string
  unionId?: string
  province?: string
  balance?: number
  id?: string
  if_inst?: string
  lmnid?: string
  name?: string
  phone?: string
}

export interface UserInfoModel extends Model {
  state: UserInfo
}

const model: UserInfoModel = {
  namespace: 'user',
  state: {},
  actions: {
    save: (state, action) => {
      return {
        ...state,
        ...action.user,
      }
    },
    reset: (state, action) => {
      return {
        ...action.user,
      }
    },
    clean: () => {
      console.log('clean')
      return {}
    },
  },
}

export default model
